package com.example.controller;

import com.example.pojo.LabourContract;
import com.example.service.ILabourContractService;
import com.example.vo.ResultVo;
import com.example.vo.per.LContractByAll;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import java.util.Map;

/**
 * <p>
 * 劳动合同表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-04-24
 */
@RestController
@RequestMapping("/labourContract")
@Api(tags = "劳动合同表",value = "")
@CrossOrigin(allowCredentials = "true")
public class LabourContractController {

    @Autowired
    private ILabourContractService ilcs;

    @PostMapping("/itf")
    @ApiModelProperty("多条件查询所有合同信息")
    public ResultVo initInter(@RequestBody LContractByAll lcba){
        PageInfo<Map<String,Object>> info = ilcs.selAllPage(lcba);
        System.err.println("合同数据 -> " + info);
        if (info != null){
            return ResultVo.response(info);
        }
        return ResultVo.error();
    }

    @GetMapping("")
    @ApiModelProperty("统计合同签约数量")
    public ResultVo transfercountByLcm(){
        return ResultVo.response(ilcs.transfercountByLcm());
    }

    @PostMapping("")
    @ApiModelProperty("新增合同记录 - 修改合同状态")
    public ResultVo addLC(@RequestBody LabourContract lc){
        System.err.println("--- > " + lc);
        Integer integer = ilcs.confirmRenew(lc);
        if (integer > 0){
            return ResultVo.ok();
        }
        return ResultVo.error();
    }
}
